<template>
  <el-card class="unit-detail-card">
    <div slot="header" class="card-header">
      <span>单元详情</span>
    </div>
    <el-form label-position="left" label-width="80px" class="detail-form">
      <el-form-item label="*小区名称">
        <span>{{tabledata.communityname }}</span>
      </el-form-item>
      <el-form-item label="*单元名称">
        <span>{{ tabledata.unitname }}</span>
      </el-form-item>
      <el-form-item label="*栋数">
        <span>{{ tabledata.unitnum }}</span>
      </el-form-item>
      <el-form-item label="*状态">
        <span>{{ tabledata.unitstatus }}</span>
      </el-form-item>
      <el-form-item label="咨询问候">
       <span v-html="tabledata.unitcontext"></span>
      </el-form-item>
    </el-form>
    <div class="action-buttons">
      <el-button type="primary" @click="handleGoBack">返回</el-button>
      <el-button type="primary" @click="handleEdit">编辑</el-button>
    </div>
  </el-card>
</template>

<script>
export default {
  name: "UnitDetail",
  data() {
    return {
        id:"",
        token:"",
        tabledata:{},
      
     
    };
  },
  
created() {
    this.id=sessionStorage.getItem("id")
     this.token = sessionStorage.getItem("token");
    this.getList()
  },
  methods: {
     getList() {
      this.$axios
        .get(`/house/getDetailId?id=${this.id}&token=${this.token}`
         
        )
        .then((res) => {
          this.tabledata = res.data[0];
          console.log(res);
          console.log(this.tabledata ,"tabldata");
        })
        .catch((err) => {
          console.log(err);
        });
    },
    handleGoBack() {
      // 返回逻辑，如路由跳转
      this.$router.push("/house/unit");
    },
    handleEdit() {
      // 编辑逻辑，如跳转到编辑页
      this.$router.push("/house/edit");
      sessionStorage.setItem("id",this.id)
    },
  },
};
</script>

<style scoped>
.unit-detail-card {
  margin: 20px;
}
.card-header {
  font-size: 16px;
  font-weight: bold;
  color: #409EFF;
}
.detail-form {
  margin-bottom: 20px;
}
.action-buttons {
  text-align: right;
}
.action-buttons .el-button {
  margin-left: 10px;
}
</style>












